﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;

namespace HF.Repository
{
    public interface IRepository<T> : IReadonlyRepository<T>
    {
        void Create(T model);
        void Create(T model, IDbTransaction transaction);
        void Create(IEnumerable<T> list, IDbTransaction transaction);

        void Update(T model);
        void Update(T model, IDbTransaction transaction);
        void Update(IEnumerable<T> list, IDbTransaction transaction);


        void Update(Expression<Func<T, T>> action, Expression<Predicate<T>> where);
        void Update(Expression<Func<T, T>> action, Expression<Predicate<T>> where, IDbTransaction transaction);





        void CreateOrUpdate(T model);
        void CreateOrUpdate(T model, IDbTransaction transaction);

        void Delete(T model);
        void Delete(T model, IDbTransaction transaction);


        void Delete(Expression<Predicate<T>> where);
        void Delete(Expression<Predicate<T>> where, IDbTransaction transaction);
    }


    public interface IRepository
    {
        void Create(RepositoryModel model);
        void Create(RepositoryModel model, IDbTransaction transaction);

        void Update(RepositoryModel model);
        void Update(RepositoryModel model, IDbTransaction transaction);

        void CreateOrUpdate(RepositoryModel model);
        void CreateOrUpdate(RepositoryModel model, IDbTransaction transaction);

        void Delete(RepositoryModel model);
        void Delete(RepositoryModel model, IDbTransaction transaction);
    }
}